<%@page import="com.sun.org.apache.xerces.internal.impl.dv.xs.DateDV"%>
<%@page import="java.util.Date"%>
<%@page import="java.sql.Timestamp"%>
<%@page import="com.wanmait.hotelManage.vo.Pager"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.text.DateFormat"%>
<%@page import="java.util.List"%>
<%@page import="com.wanmait.hotelManage.vo.Order"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%
    String path=request.getContextPath();
    List<Order>orders=(List<Order>)request.getAttribute("orders");
    Integer ida=(Integer)request.getAttribute("id");
    List<Double> price=(List<Double>)request.getAttribute("pricess");
    %>
 <table class="result-tab" width="100%">
                        <tr>
                            <th>ID</th>
                            <th>客人姓名</th>
                            <th>房间</th>
                            <th>电话</th>
                            <th>早餐</th>
                            <th>订单创建时间</th>
                            <th>开始时间</th>
                            <th>结束时间</th>
                            <th>折后价钱</th>
                            <th>车辆</th>
                            <th>车开始时间</th>
                            <th>车结束时间</th>
                            <th>是否退订</th>
                        </tr>
                        <%
                        if(orders!=null){
                        	DateFormat df=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                        	DateFormat dfm=new SimpleDateFormat("yyyy-MM-dd");
                        	for(int i=0;i<orders.size();i++){
                        		Order order=orders.get(i);
                        		Double prices=price.get(i);
                        		String inputTime=df.format(order.getInputTime());
                        		String startTime=dfm.format(order.getStartTime());
                        		String endTime=dfm.format(order.getEndTime());
                        		String carStartTime="没有";
                        		String carEndTime="没有";
                        		if(order.getCarStartTime()!=null){
                        		carStartTime=df.format(order.getCarStartTime());
                        		}
                        		if(order.getCarEndTime()!=null){
                        		carEndTime=df.format(order.getCarEndTime());
                        		}
                        		%>
                        		<tr>
                            <td><%=order.getId() %></td>
                            <td><%=order.getName() %></td>
                            <td><%=order.getRoomType().getTitle() %></td>
                            <td><%=order.getTelephoneNumber() %></td>
                            <td class="breakfastid"><%=order.getBreakfast() %></td>
                            <td><%=inputTime %></td>
                            <td><%=startTime %></td>
                            <td><%=endTime %></td>
                            <td><%=prices %></td>
                            <td class="carid"><%=order.getCar() %></td>
                            <td><%=carStartTime %></td>
                            <td><%=carEndTime %></td>
                            <td class="enableid"><%=order.getEnable() %></td>
                        </tr>
                        		<%
                        	}
                        }
                        %>
                    </table>
                    <div class="qwe">
                    <%
                    Pager pager=(Pager)request.getAttribute("pager");
                    if(pager!=null){
                    	 int start= 1;
                         int end =pager.getPageCount();
                         if(pager.getPageCount()>5){
                        	 start=pager.getPageNo()-2<1?1:pager.getPageNo()-2;
                        	 end=start+4;
                        	 if(end>pager.getPageCount()){
                        		 end=pager.getPageCount();
                        		 start=end-4;
                        	 }
                         }
                         %>
                         [<a class="ok" href="javascript:void(0)">上一页</a>]
                         <%
                    	for(int i=start;i<=end;i++){
                    		if(pager.getPageNo()!=i){
                    		%>
                    		[<a class="number" href="javascript:void(0)"><%=i %></a>]
                    		<%
                    	}else{
                    		%>
                    		[<a class="aaa" href="javascript:void(0)"><%=i %></a>]
                    		<%
                    	}
                    }
                         %>
                         [<a class="no" href="javascript:void(0)">下一页</a>]
                         <%
                    }
                    %>
                    </div>
                    <script>
$(".aaa").css("color","red");
</script>
					<style>
					.qwe{
						text-align:center;
						}
						.aaa{
						text-align:center;
						}
					</style>
					<script>
                    $(function(){
                    	$(".no").click(function(){
                    		/* $(".number").css("color","black");
                    		$(this).css("color","red"); */
                    		var content=<%=pager.getPageNo()%>;
                    		if(content<<%=pager.getPageCount()%>){
                    			content++;
                    		}
                    		$.ajax({
                    			url:"<%=path%>/manage/UserinfoManageServlet?action=OrderInformationTwo&id=<%=ida%>",
                    				data:{pageNo:content},
                    					success:function(msg){
                    						$(".result-content").html(msg);
                    					}
                    		})
                    	})
                    $(".ok").click(function(){
                    /* $(".number").css("color","black");
                    $(this).css("color","red"); */
                    var content=<%=pager.getPageNo()%>;
                    if(content>1){
                    	content--;
                    }
                    $.ajax({
                    url:"<%=path%>/manage/UserinfoManageServlet?action=OrderInformationTwo&id=<%=ida%>",
                    data:{pageNo:content},
                    success:function(msg){
                    	$(".result-content").html(msg);
                    }
                    })
                    })
                    	$(".number").click(function(){
                   		var content=$(this).html();
                   		$.ajax({
                   			url:"<%=path%>/manage/UserinfoManageServlet?action=OrderInformationTwo&id=<%=ida%>",
                   			data:{pageNo:content},
                   			success:function(msg){
                   				console.log(1);
                   				$(".result-content").html(msg);
                   			}
                   		})
                   	})
                   	$(".aaa").click(function(){
                   		var content=$(this).html();
                   		$.ajax({
                   			url:"<%=path%>/manage/UserinfoManageServlet?action=OrderInformationTwo&id=<%=ida%>",
                   			data:{pageNo:content},
                   			success:function(msg){
                   				$(".result-content").html(msg);
                   			}
                   		})
                   	})
                   	$(".carid").each(function(){
			var check=$(this).html();
			
			if(check=="false"){
				$(this).html("没有");
			}else if(check=="true"){
				$(this).html("有");
			} 
		})
			$(".breakfastid").each(function(){
			var check=$(this).html();
			
			if(check=="false"){
				$(this).html("没有");
			}else if(check=="true"){
				$(this).html("有");
			} 
		})
		$(".enableid").each(function(){
			var check=$(this).html();
			
			if(check=="false"){
				$(this).html("退订");
			}else if(check=="true"){
				$(this).html("不退订");
			} 
		})
                    })
                    </script>